package org.srunpass.bitmap.expression;

import java.util.LinkedList;

import org.srunpass.bitmap.enums.OperateTypeEnum;
import org.srunpass.bitmap.condition.Condition;

import lombok.Getter;

/**
 * @author srunpass
 * @version Id: Expression, v 0.1 2025/6/30 10:52 srunpass Exp $
 */
@Getter
public class Expression {

    private Condition                   condition;
    // condition or expressions
    private LinkedList<OperateTypeEnum> operates;
    private LinkedList<Expression>      expressions;

    public Expression(Condition condition) {
        this.condition = condition;
        this.operates = null;
        this.expressions = null;
    }

    public void opt(OperateTypeEnum opt, Expression expression) {
        if (this.condition != null) {
            this.operates = new LinkedList<>();
            this.expressions = new LinkedList<>();
            this.expressions.push(new Expression(this.condition));
            this.condition = null;
        }
        this.operates.push(opt);
        this.expressions.push(expression);
    }

}
